﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace STS.Pacjent
{
    public partial class pokazBadaniaKrwi : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Master.FindControl("NavigationMenuR").Visible = false;
            if (Main.idpacjenta == 0)
            {
                tekst.Text = "Wybierz pacjenta!";
                tekst.Visible = true;
                DropDownList1.Visible = false;
                Button1.Visible = false;
                Panel2.Visible = false;
            }
            else
            {
                
                id_pacjenta.Text = Main.idpacjenta.ToString();
                Panel2.Visible = false;
            }
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Panel2.Visible = true;
            baza db = new baza();
            var ud = db.badania_krews.SingleOrDefault(fbu => fbu.id_badania == Convert.ToInt32(DropDownList1.SelectedValue));
            WBC.Text = ud.WBC.ToString();
            RBC.Text = ud.RBC.ToString();
            hemo.Text = ud.Hemoglobina.ToString();
            plytki.Text = ud.Plytki_krwi.ToString();
            potas.Text = ud.potas.ToString();
            if ((ud.WBC < 4.40) || (ud.WBC > 11.30))
            {
                uwagaWBC.Text = "UWAGA - 4,44 - 11,30";
                uwagaWBC.Visible = true;
            }
            if ((ud.Hemoglobina < 13.00) || (ud.Hemoglobina > 17.2))
            {
                uwagahemo.Text = "UWAGA - 13.00 - 17.2";
                uwagahemo.Visible = true;
            }
            if ((ud.RBC < 4.20) || (ud.Hemoglobina > 5.60))
            {
                uwagaRBC.Text = "UWAGA - 4.20-5.60";
                uwagaRBC.Visible = true;
            }
            if ((ud.Plytki_krwi < 150) || (ud.Plytki_krwi > 400))
            {
                uwagahemo.Text = "UWAGA - 150-400";
                uwagahemo.Visible = true;
            }
            if ((ud.potas < 3.5) || (ud.potas > 5.1))
            {
                uwagapotas.Text = "UWAGA - 3.5-5.1";
                uwagapotas.Visible = true;
            }
            if ((ud.kreatynina < 0.7) || (ud.kreatynina > 1.20))
            {
                uwagapotas.Text = "UWAGA - 0.7-1.20";
                uwagapotas.Visible = true;
            }
        }

        protected void Drukuj_Click(object sender, EventArgs e)
        {
            Session["ctrl"] = Panel2;
            ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('Print.aspx','PrintMe','height=300px,width=300px,scrollbars=1');</script>");
        }
    }
}